<?php
include('include/config.inc.php');
///// Select technician2 : Start
if(isset($_GET['technicianId']))
{
	$abc = array();
  $technicianId = $_GET['technicianId'];
  $targateDate = $_REQUEST['targetedDateYearAj']."-".$_REQUEST['targetedDateMonthAj']."-".$_REQUEST['targetedDateDayAj'];
  $selectTechnician = "SELECT technicianId, firstName, lastName, 1 AS selected
                       FROM technician
                      WHERE technicianId IN (SELECT technicianId
                                               FROM techallocation
                                              WHERE date = '".$targateDate."')
                        AND technicianId !=".$technicianId."
                        AND userType = 'None' 
                     UNION
                     SELECT technicianId, firstName, lastName, 0 AS selected
                       FROM technician
                      WHERE technicianId NOT IN (SELECT technicianId
                                               FROM techallocation
                                              WHERE date = '".$targateDate."')
                       AND technicianId !=".$technicianId." 
                       AND userType = 'None' ";
  $selectTechnicianResult = mysql_query($selectTechnician);
  $c = 0;
  while($technicianRow = mysql_fetch_array($selectTechnicianResult))
  {
  	if($technicianRow['selected'] == 1)
    {
      $abc[$c] =  "<option value='".$technicianRow['technicianId']."' style='color: red;'>".$technicianRow['firstName']." ".$technicianRow['lastName']."</option>";
    }
    else
    {
      $abc[$c]  =  "<option value='".$technicianRow['technicianId']."' style='color: blue;'>".$technicianRow['firstName']." ".$technicianRow['lastName']."</option>";
    }
    $c++;
 
  }
}
///// Select technician2 : End
///// Select technician3 : Start
if(isset($_GET['technicianId2']))
{
	$abc = array();
	$technicianId = $_GET['technicianId'];
	$technicianId2 = $_GET['technicianId2'];
	$targateDate = $_REQUEST['targetedDateYearAj']."-".$_REQUEST['targetedDateMonthAj']."-".$_REQUEST['targetedDateDayAj'];
  $selectTechnician = "SELECT technicianId, firstName, lastName, 1 AS selected
                         FROM technician
                        WHERE technicianId IN (SELECT technicianId
                                                 FROM techallocation
                                                WHERE date = '".$targateDate."')
                          AND technicianId !=".$technicianId."
                          AND technicianId != ".$technicianId2."
                          AND userType = 'None' 
                       UNION
                       SELECT technicianId, firstName, lastName, 0 AS selected
                         FROM technician
                        WHERE technicianId NOT IN (SELECT technicianId
                                                 FROM techallocation
                                                WHERE date = '".$targateDate."')
                         AND technicianId !=".$technicianId." 
                         AND technicianId != ".$technicianId2."
                         AND userType = 'None' ";
  $selectTechnicianResult = mysql_query($selectTechnician);
  $c = 0;
  while($technicianRow = mysql_fetch_array($selectTechnicianResult))
  {
  
    if($technicianRow['selected'] == 1)
    {
      $abc[$c] =  "<option value='".$technicianRow['technicianId']."' style='color: red;'>".$technicianRow['firstName']." ".$technicianRow['lastName']."</option>";
    }
    else
    {
      $abc[$c]  =  "<option value='".$technicianRow['technicianId']."' style='color: blue;'>".$technicianRow['firstName']." ".$technicianRow['lastName']."</option>";
    }
    $c++;
 
  }
}
///// Select technician3 : End
///// Select technician4 : Start
if(isset($_GET['technicianId3']))
{
	$abc = array();
  $technicianId = $_GET['technicianId'];
	$technicianId2 = $_GET['technicianId2'];
	$technicianId3 = $_GET['technicianId3'];
	$targateDate = $_REQUEST['targetedDateYearAj']."-".$_REQUEST['targetedDateMonthAj']."-".$_REQUEST['targetedDateDayAj'];
	$selectTechnician = "SELECT technicianId, firstName, lastName, 1 AS selected
                         FROM technician
                        WHERE technicianId IN (SELECT technicianId
                                                 FROM techallocation
                                                WHERE date = '".$targateDate."')
                          AND technicianId !=".$technicianId."
                          AND technicianId != ".$technicianId2."
                          AND technicianId != ".$technicianId3."
                          AND userType = 'None' 
                       UNION
                       SELECT technicianId, firstName, lastName, 0 AS selected
                         FROM technician
                        WHERE technicianId NOT IN (SELECT technicianId
                                                 FROM techallocation
                                                WHERE date = '".$targateDate."')
                         AND technicianId !=".$technicianId." 
                         AND technicianId != ".$technicianId2."
                         AND technicianId != ".$technicianId3."
                         AND userType = 'None' ";
  
  $selectTechnicianResult = mysql_query($selectTechnician);
  $c = 0;
  while($technicianRow = mysql_fetch_array($selectTechnicianResult))
  {
  
    if($technicianRow['selected'] == 1)
    {
      $abc[$c] =  "<option value='".$technicianRow['technicianId']."' style='color: red;'>".$technicianRow['firstName']." ".$technicianRow['lastName']."</option>";
    }
    else
    {
      $abc[$c]  =  "<option value='".$technicianRow['technicianId']."' style='color: blue;'>".$technicianRow['firstName']." ".$technicianRow['lastName']."</option>";
    }
    $c++;
 
  }
}
///// Select technician4 : End
///// Select technician5 : Start
if(isset($_GET['technicianId4']))
{
	$abc = array();
  $technicianId = $_GET['technicianId'];
	$technicianId2 = $_GET['technicianId2'];
	$technicianId3 = $_GET['technicianId3'];
	$technicianId4 = $_GET['technicianId4'];
	$targateDate = $_REQUEST['targetedDateYearAj']."-".$_REQUEST['targetedDateMonthAj']."-".$_REQUEST['targetedDateDayAj'];
	$selectTechnician = "SELECT technicianId, firstName, lastName, 1 AS selected
                         FROM technician
                        WHERE technicianId IN (SELECT technicianId
                                                 FROM techallocation
                                                WHERE date = '".$targateDate."')
                          AND technicianId !=".$technicianId."
                          AND technicianId != ".$technicianId2."
                          AND technicianId != ".$technicianId3."
                          AND technicianId != ".$technicianId4."
                          AND userType = 'None' 
                       UNION
                       SELECT technicianId, firstName, lastName, 0 AS selected
                         FROM technician
                        WHERE technicianId NOT IN (SELECT technicianId
                                                 FROM techallocation
                                                WHERE date = '".$targateDate."')
                         AND technicianId !=".$technicianId." 
                         AND technicianId != ".$technicianId2."
                         AND technicianId != ".$technicianId3."
                         AND technicianId != ".$technicianId4."
                         AND userType = 'None' ";
  $selectTechnicianResult = mysql_query($selectTechnician);
  $c = 0;
  while($technicianRow = mysql_fetch_array($selectTechnicianResult))
  {
  
    if($technicianRow['selected'] == 1)
    {
      $abc[$c] =  "<option value='".$technicianRow['technicianId']."' style='color: red;'>".$technicianRow['firstName']." ".$technicianRow['lastName']."</option>";
    }
    else
    {
      $abc[$c]  =  "<option value='".$technicianRow['technicianId']."' style='color: blue;'>".$technicianRow['firstName']." ".$technicianRow['lastName']."</option>";
    }
    $c++;
 
  }
}
///// Select technician5 : End
include("./bottom.php");
$smarty->assign("abc",$abc);
$smarty->display("techAllocationEditAj.tpl");
?>